/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package control.benhan;

import com.toedter.calendar.JDateChooser;
import java.util.Date;
import java.util.List;
import javax.swing.ButtonGroup;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import model.dao.benhan.BenhAnDAO;
import javax.swing.JTable;
import model.entity.BenhAn;
/**
 *
 * @author Admin
 */
public class BAXoaDialog_CTrl {
    
     public static final void xoaBA(JTable table, JTextField tfMaBA, JTextField tfTenBenh, JDateChooser jdateNgayBD, JDateChooser jdateNgayKT,ButtonGroup bgTrangThai, JTextArea taGhiChu){
        try {
            int maBA = Integer.parseInt(tfMaBA.getText());
            String tenBenh = tfTenBenh.getText();
            Date ngayBD = jdateNgayBD.getDate();
            Date ngayKT = jdateNgayKT.getDate();
            
            int a = bgTrangThai.getButtonCount();
            String trangThai = bgTrangThai.getSelection().getActionCommand();
            System.out.println(trangThai);
            
            String ghiChu = taGhiChu.getText();
            
            boolean ba = BenhAnDAO.xoaBenhAn(maBA, tenBenh, ngayBD, ngayKT, trangThai, ghiChu);
			List<BenhAn>benhAn = BenhAnDAO.loaddAllBenhAn();
            BAMainPanel_Ctrl.loadBenhAnLenTable(benhAn, table);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
}
